package com.hmall.item;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回结果的实体类
 *
 * @Author Vsunks.v
 * @Date 2022/7/8 20:52
 * @Description: 返回结果的实体类
 * @Created by 15198
 */
@Data
@AllArgsConstructor
@NoArgsConstructor

public class Result<T> {

    private Integer code;
    private String msg;
    private  T data;
    private Map map  = new HashMap();

    public static <T> Result success(T s, String msg) {
        Result<T> r = new Result<T>();
        r.data = s;
        r.msg = msg;
        r.code = 1;
        return r;
    }
    public static <T> Result error(String msg) {
        Result r = new Result();
        r.msg = msg;
        r.code = 0;
        return r;
    }
    public static <T>Result success(T t) {
        Result<T>r = new Result<T>();
        r.data = t;
        r.code = 1;
        return r;
    }
}
